/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xyuser.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xyuser.param.XyUserParam;
import vip.xiaonuo.modular.xyuser.service.XyUserService;
import vip.xiaonuo.modular.xyuser.entity.XyUser;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 用户信息控制器
 *
 * @author yanwei
 * @date 2023-05-05 15:44:27
 */
@RestController
@Api(tags = "后台管理 用户信息 相关APIS")
@AdminVersionSwagger
public class XyUserController {

    @Resource
    private XyUserService xyUserService;

    /**
     * 查询用户信息
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @GetMapping("/xyUser/page")
    @BusinessLog(title = "用户信息_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("用户信息_查询")
    public Result<PageResult<XyUser>> page(XyUserParam xyUserParam) {
        PageResult<XyUser> page = xyUserService.page(xyUserParam);
        return success(page);
    }

    /**
     * 添加用户信息
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @PostMapping("/xyUser/add")
    @BusinessLog(title = "用户信息_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("用户信息_增加")
    public Result add(@RequestBody @Validated(XyUserParam.add.class) XyUserParam xyUserParam) {
            xyUserService.add(xyUserParam);
        return success();
    }

    /**
     * 删除用户信息，可批量删除
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @PostMapping("/xyUser/delete")
    @BusinessLog(title = "用户信息_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("用户信息_删除")
    public Result delete(@RequestBody @Validated(XyUserParam.delete.class) List<XyUserParam> xyUserParamList) {
            xyUserService.delete(xyUserParamList);
        return success();
    }

    /**
     * 编辑用户信息
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @PostMapping("/xyUser/edit")
    @BusinessLog(title = "用户信息_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("用户信息_编辑")
    public Result edit(@RequestBody @Validated(XyUserParam.edit.class) XyUserParam xyUserParam) {
            xyUserService.edit(xyUserParam);
        return success();
    }

    /**
     * 查看用户信息
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @GetMapping("/xyUser/detail")
    @BusinessLog(title = "用户信息_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("用户信息_查看")
    public Result<XyUser> detail(@Validated(XyUserParam.detail.class) XyUserParam xyUserParam) {
        XyUser detail =   xyUserService.detail(xyUserParam);
        return success(detail);
    }

    /**
     * 用户信息列表
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @GetMapping("/xyUser/list")
    @BusinessLog(title = "用户信息_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("用户信息_列表")
    public Result<List<XyUser>> list(XyUserParam xyUserParam) {
        List<XyUser> list  =   xyUserService.list(xyUserParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-05 15:44:27
     */
    @Permission
    @GetMapping("/xyUser/export")
    @BusinessLog(title = "用户信息_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("用户信息_导出")
    public void export(XyUserParam xyUserParam) {
        xyUserService.export(xyUserParam);
    }

}
